package com.foreknow.demo8;

/**
 * 静态变量：可以被多个对象共享
 * 作用：可以作为累加器来使用
 */
public class StaticVar {

    public static int i;
    public StaticVar() {
        i++;
        System.out.println(i);
    }

    public static void main(String[] args) {
        StaticVar staticvar1 = new StaticVar();
        StaticVar staticvar2 = new StaticVar();
        StaticVar staticvar3 = new StaticVar();
        StaticVar staticvar4 = new StaticVar();

    }

}














